import b from 'crypto-js/enc-base64';
import u from 'crypto-js/enc-utf8';
import h from 'crypto-js/hmac-sha1';

export default function (data) {
  if (_.isNil(data)) return;
  const str = JSON.stringify(data);
  const d = b.stringify(u.parse(str));
  const k = h(str, 'hyde').toString();
  return b.stringify(u.parse(d + '.' + k));
}
